Skip to content

fix(trace): convert file path to URI in StdinServer._loadTrace#39097

Closed
li-zhixin wants to merge 1 commit intomicrosoft:mainfrom
li-zhixin:fix/stdin-server-trace-uri
Closed

fix(trace): convert file path to URI in StdinServer._loadTrace#39097
li-zhixin wants to merge 1 commit intomicrosoft:mainfrom
li-zhixin:fix/stdin-server-trace-uri

Conversation

@li-zhixin
Copy link

Summary

Fix trace viewer failing when receiving trace paths via stdin (used by VS Code extension for live trace).

  • StdinServer._loadTrace() now calls validateTraceUrl() to convert file paths to file?path= URI format
  • This makes stdin path handling consistent with runTraceViewerApp() and runTraceInBrowser()

Problem

After #38566, the trace viewer expects trace URIs in file?path=... format, but StdinServer._loadTrace() was still sending raw file paths. This caused the Service Worker to attempt fetching the raw path directly, resulting in:

Not allowed to load local resource: file:///C:/Users/.../traces/xxx.json

Root Cause

In commit 185bfb7, validateTraceUrl() was updated to convert file paths to URI format, but StdinServer._loadTrace() was not updated to use this function.

Fix

  private _loadTrace(traceUrl: string) {
-   this._traceUrl = traceUrl;
+   const validatedUrl = validateTraceUrl(traceUrl);
+   this._traceUrl = validatedUrl;
    clearTimeout(this._pollTimer);
-   this.sendEvent?.('loadTraceRequested', { traceUrl });
+   this.sendEvent?.('loadTraceRequested', { traceUrl: validatedUrl });
  }

Test Plan

  • Verified VS Code extension (v1.1.17) live trace now works with this fix
  • Existing trace viewer tests should pass

Fixes #39096

When receiving trace paths via stdin (used by VS Code extension),
StdinServer._loadTrace() was sending raw file paths to the frontend
instead of converting them to `file?path=` URI format.

This caused the trace viewer to fail with "Not allowed to load local
resource: file:///" error because the Service Worker tried to fetch
the raw path directly.

The fix calls validateTraceUrl() to properly convert the file path
to URI format before sending to the frontend, consistent with how
other entry points (runTraceViewerApp, runTraceInBrowser) handle
trace paths.

Fixes microsoft#39096
@li-zhixin
Copy link
Author

Closing this PR as the fix has been implemented in #39121 by @Skn0tt. Thanks for picking this up! 🙏

@li-zhixin li-zhixin closed this Feb 4, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

fix(trace): StdinServer._loadTrace does not convert file path to URI format

1 participant